import globals from 'globals'
import pluginJs from '@eslint/js'
import tseslint from 'typescript-eslint'
import pluginVue from 'eslint-plugin-vue'
import path from 'path'
import { FlatCompat } from '@eslint/eslintrc'
import { fileURLToPath } from 'url'
import eslintConfigPrettier from 'eslint-config-prettier'
// mimic CommonJS variables -- not needed if using CommonJS
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
  baseDirectory: __dirname
})
/** @type {import('eslint').Linter.Config[]} */
export default [
  { files: ['**/*.{js,mjs,cjs,ts,vue}'] },
  { languageOptions: { globals: globals.browser } },
  pluginJs.configs.recommended,
  ...tseslint.configs.recommended,
  ...pluginVue.configs['flat/essential'],
  ...compat.extends('./types/.eslintrc-auto-import.json'),
  { files: ['**/*.vue'], languageOptions: { parserOptions: { parser: tseslint.parser } } },
  {
    ignores: ['dist/**', 'node_modules/**', 'src/vite-env.d.ts']
  },
  {
    rules: {
      'vue/multi-word-component-names': 'off',
      'no-control-regex': 'off'
    }
  },
  eslintConfigPrettier
]
